using System;
using System.Collections.Generic;

namespace MEA.AE_Data.Config
{
	public abstract class ConfigFlash
	{
		public enum e_timingParameter
		{
			eraseFlash,
			writeFlash,
			Count
		}

		public enum e_Flash_States
		{
			INIT,
			PARSE_CONTAINER,
			VERIFY_FLASH_CONDITIONS,
			FCM_CHECK,
			EEPROM_BACKUP,
			FILTER_BLOCKS_ALREADY_IN_ECU,
			WRITE_FINGERPRINT,
			ERASE_FIRST_BLOCK,
			WRITE_FIRST_BLOCK,
			ERASE_BLOCKS,
			WRITE_BLOCKS,
			RESET_ECU,
			EEPROM_RESTORE,
			EEPROM_VERIFY,
			DTC_MBLOCK_VERIFY,
			FINISHED,
			ERROR
		}

		private static bool ignoreFlashCond;

		private static bool fctClearText;

		private static bool flashVerbose;

		private static string engineLog_AutoBackup_Filename;

		private static List<List<byte>> timingParameters;

		private static string scriptRoot;

		private static int retryAttepts;

		public static bool IgnoreFlashCond
		{
			get
			{
				return ignoreFlashCond;
			}
			set
			{
				ignoreFlashCond = value;
			}
		}

		public static bool FctClearText
		{
			get
			{
				return fctClearText;
			}
			set
			{
				fctClearText = value;
			}
		}

		public static bool FlashVerbose
		{
			get
			{
				return flashVerbose;
			}
			set
			{
				flashVerbose = value;
			}
		}

		public static string EngineLog_AutoBackup_Filename
		{
			get
			{
				return engineLog_AutoBackup_Filename;
			}
			set
			{
				engineLog_AutoBackup_Filename = value;
			}
		}

		public static string ScriptRoot
		{
			get
			{
				return scriptRoot;
			}
		}

		public static int RetryAttepts
		{
			get
			{
				return retryAttepts;
			}
		}

		static ConfigFlash()
		{
			ignoreFlashCond = false;
			fctClearText = false;
			flashVerbose = false;
			engineLog_AutoBackup_Filename = "Flash_Autosave_Engine_Log";
			retryAttepts = 5;
			InitTimingParameters();
			scriptRoot = "E4W_Script";
		}

		private static void InitTimingParameters()
		{
			timingParameters = new List<List<byte>>(2);
			for (int i = 0; i < timingParameters.Capacity; i++)
			{
				timingParameters.Add(new List<byte>());
			}
			timingParameters[0] = new List<byte>(new byte[5] { 0, 160, 255, 16, 10 });
			timingParameters[1] = new List<byte>(new byte[5] { 0, 40, 0, 4, 10 });
		}

		public static List<byte> TimingParameterGet(e_timingParameter e_para)
		{
			if (e_para == e_timingParameter.Count)
			{
				throw new Exception("ConfigFlash.TimingParameter parameter e_para must not equal Count");
			}
			return timingParameters[(int)e_para];
		}

		public static void TimingParameterSet(e_timingParameter e_para, List<byte> parameters)
		{
			if (e_para == e_timingParameter.Count)
			{
				throw new Exception("ConfigFlash.TimingParameter parameter e_para must not equal Count");
			}
			if (parameters.Count == 5)
			{
				timingParameters[(int)e_para] = parameters;
			}
		}
	}
}
